package com.ruoyi.business.domain;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;

import java.util.Date;
import java.util.Map;

import static com.ruoyi.common.utils.DateUtils.YYYY_MM_DD;

/**
 * @author danghf
 * @date 2024/04/27 18:23:25
 * @tableName leave_request_form
 * 请假申请表单
 */
public class LeaveRequestForm {

    /**
     * 主键id && 业务标识
     */
    private Long id;
    /**
     * 用户id
     */
    private Long userId;

    private String username;
    /**
     * 请假开始时间
     */
    private Date startTime;
    /**
     * 请假结束时间
     */
    private Date endTime;
    /**
     * 请假原因
     */
    private String reason;
    /**
     * 状态 0:待审批 1:已通过 2:已拒绝
     */
    private Integer status;
    /**
     * 创建时间
     */
    private Date createTime;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public static LeaveRequestForm buildByMap(Map<String, Object> map){
        LeaveRequestForm leaveRequestForm = new LeaveRequestForm();
        leaveRequestForm.setId((Long) map.get("id"));
        leaveRequestForm.setUserId((Long) map.get("userId"));
        leaveRequestForm.setStartTime(DateUtils.dateTime(YYYY_MM_DD, (String) map.get("startTime")));
        leaveRequestForm.setEndTime(DateUtils.dateTime(YYYY_MM_DD, (String) map.get("endTime")));
        leaveRequestForm.setReason((String) map.get("reason"));
        leaveRequestForm.setStatus((Integer) map.get("status"));
        if (StringUtils.isEmpty((String) map.get("createTime"))){
            return leaveRequestForm;
        }
        leaveRequestForm.setCreateTime(DateUtils.dateTime(YYYY_MM_DD, (String) map.get("createTime")));
        return leaveRequestForm;
    }
}
